/*
 * w25q.h
 *
 *  Created on: 2021-03-17
 *      Author: chens
 */

#ifndef INC_W25Q_H_
#define INC_W25Q_H_

#include "main.h"

#define W25Q_MANUFACTURER 0xef
#define W25Q_TYPE 0x40
#define W25Q_CAPACITY 0x16

typedef struct
{
    uint8_t manufacturer;
    uint8_t type;
    uint8_t capacity;
}JEDEC_ID_t;

void W25Q_Init(void);

int W25Q_Reset(void);
int W25Q_ReadId(JEDEC_ID_t *id);
int W25Q_WriteEnable(void);
int W25Q_FlashInfo(uint32_t *devStartAddr, uint32_t *eraseNum, uint32_t *eraseSize);
int W25Q_EraseChip(void);
int W25Q_ErasePart(uint32_t addr);
int W25Q_Read(uint32_t addr, void *data, uint32_t len);
int W25Q_Write(uint32_t addr, const void *data, uint32_t len);
int W25Q_MemoryMapped(void);

#endif /* INC_W25Q_H_ */
